<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: MQTT client</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__mqtt.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">Modules</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">MQTT client<div class="ingroups"><a class="el" href="group__apps.html">Applications</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:group__mqtt__opts"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt__opts.html">Options</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structmqtt__connect__client__info__t.html">mqtt_connect_client_info_t</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:gaa8632baff6bbb5004385998918f1e6bd"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gaa8632baff6bbb5004385998918f1e6bd">MQTT_PORT</a>&#160;&#160;&#160;<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0a172d486d82c552ef3540cf8d61b14b22">LWIP_IANA_PORT_MQTT</a></td></tr>
<tr class="separator:gaa8632baff6bbb5004385998918f1e6bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6610174f17b9ecbcf2bc66a4fd5a6b0f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga6610174f17b9ecbcf2bc66a4fd5a6b0f">MQTT_TLS_PORT</a>&#160;&#160;&#160;<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0ab833e9dc7646bd7affde45691bc66601">LWIP_IANA_PORT_SECURE_MQTT</a></td></tr>
<tr class="separator:ga6610174f17b9ecbcf2bc66a4fd5a6b0f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga83d6a6d811b201a74d793bc1b5d4e029"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga83d6a6d811b201a74d793bc1b5d4e029">mqtt_subscribe</a>(client,  topic,  qos,  cb,  arg)&#160;&#160;&#160;<a class="el" href="group__mqtt.html#gafdb39d4a9758f98c02451aaa9a9b3103">mqtt_sub_unsub</a>(client, topic, qos, cb, arg, 1)</td></tr>
<tr class="separator:ga83d6a6d811b201a74d793bc1b5d4e029"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0f133ef09cbe56c46ebe2cc21afccf3f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga0f133ef09cbe56c46ebe2cc21afccf3f">mqtt_unsubscribe</a>(client,  topic,  cb,  arg)&#160;&#160;&#160;<a class="el" href="group__mqtt.html#gafdb39d4a9758f98c02451aaa9a9b3103">mqtt_sub_unsub</a>(client, topic, 0, cb, arg, 0)</td></tr>
<tr class="separator:ga0f133ef09cbe56c46ebe2cc21afccf3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:ga8558743bdb7d599a93844fbc56c9029f"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga8558743bdb7d599a93844fbc56c9029f">mqtt_connection_cb_t</a>) (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, void *arg, <a class="el" href="group__mqtt.html#ga8cf0f360ab20343af37e1d124395a77d">mqtt_connection_status_t</a> status)</td></tr>
<tr class="separator:ga8558743bdb7d599a93844fbc56c9029f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafec7e75fe6a746eef9ca411463446c81"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gafec7e75fe6a746eef9ca411463446c81">mqtt_incoming_data_cb_t</a>) (void *arg, const u8_t *data, u16_t len, u8_t flags)</td></tr>
<tr class="separator:gafec7e75fe6a746eef9ca411463446c81"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7116bb85255394cec4b1d9fa38842c29"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga7116bb85255394cec4b1d9fa38842c29">mqtt_incoming_publish_cb_t</a>) (void *arg, const char *topic, u32_t tot_len)</td></tr>
<tr class="separator:ga7116bb85255394cec4b1d9fa38842c29"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacad2bbe2cee76eaa120cc63e2f6094fd"><td class="memItemLeft" align="right" valign="top">typedef void(*&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gacad2bbe2cee76eaa120cc63e2f6094fd">mqtt_request_cb_t</a>) (void *arg, <a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> err)</td></tr>
<tr class="separator:gacad2bbe2cee76eaa120cc63e2f6094fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:ga8cf0f360ab20343af37e1d124395a77d"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga8cf0f360ab20343af37e1d124395a77d">mqtt_connection_status_t</a> { <br />
&#160;&#160;<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da074dc1d289b8e8d4aad91f6a2cb93dc1">MQTT_CONNECT_ACCEPTED</a> = 0, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da41f8aa97142be337cb639f94d9145190">MQTT_CONNECT_REFUSED_PROTOCOL_VERSION</a> = 1, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da28ffe49b0175adaa2b9a27cb4873224a">MQTT_CONNECT_REFUSED_IDENTIFIER</a> = 2, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77dade28ec1c2ce3d874e91251d683c92b2a">MQTT_CONNECT_REFUSED_SERVER</a> = 3, 
<br />
&#160;&#160;<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da290cf9037054c42022cc864cfade896a">MQTT_CONNECT_REFUSED_USERNAME_PASS</a> = 4, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77dafc4888158dd6ee84269a5f0bfdc12b17">MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_</a> = 5, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da321f5ce31b173f235de1a517fcfd00dd">MQTT_CONNECT_DISCONNECTED</a> = 256, 
<a class="el" href="group__mqtt.html#gga8cf0f360ab20343af37e1d124395a77da57153f2ab4331c6f76a9ee74e1bcfc62">MQTT_CONNECT_TIMEOUT</a> = 257
<br />
 }</td></tr>
<tr class="separator:ga8cf0f360ab20343af37e1d124395a77d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga99fb83031ce9923c84392b4e92f956b5"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom">{ <a class="el" href="group__mqtt.html#gga99fb83031ce9923c84392b4e92f956b5a79cd00d0a5a8df13207e0c49447df87f">MQTT_DATA_FLAG_LAST</a> = 1
 }</td></tr>
<tr class="separator:ga99fb83031ce9923c84392b4e92f956b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gade9850d716e81fde572cb012be795d2f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gade9850d716e81fde572cb012be795d2f">mqtt_publish</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain, <a class="el" href="group__mqtt.html#gacad2bbe2cee76eaa120cc63e2f6094fd">mqtt_request_cb_t</a> cb, void *arg)</td></tr>
<tr class="separator:gade9850d716e81fde572cb012be795d2f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafdb39d4a9758f98c02451aaa9a9b3103"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gafdb39d4a9758f98c02451aaa9a9b3103">mqtt_sub_unsub</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, const char *topic, u8_t qos, <a class="el" href="group__mqtt.html#gacad2bbe2cee76eaa120cc63e2f6094fd">mqtt_request_cb_t</a> cb, void *arg, u8_t sub)</td></tr>
<tr class="separator:gafdb39d4a9758f98c02451aaa9a9b3103"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafdfa0e65b217e92835d35858924565cf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gafdfa0e65b217e92835d35858924565cf">mqtt_set_inpub_callback</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, <a class="el" href="group__mqtt.html#ga7116bb85255394cec4b1d9fa38842c29">mqtt_incoming_publish_cb_t</a> pub_cb, <a class="el" href="group__mqtt.html#gafec7e75fe6a746eef9ca411463446c81">mqtt_incoming_data_cb_t</a> data_cb, void *arg)</td></tr>
<tr class="separator:gafdfa0e65b217e92835d35858924565cf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae7e19e236eb6122c8c39e93db6f5f53f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gae7e19e236eb6122c8c39e93db6f5f53f">mqtt_client_new</a> (void)</td></tr>
<tr class="separator:gae7e19e236eb6122c8c39e93db6f5f53f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa0fa1d985c322a9c91a51322db254882"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gaa0fa1d985c322a9c91a51322db254882">mqtt_client_free</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client)</td></tr>
<tr class="separator:gaa0fa1d985c322a9c91a51322db254882"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gadf4d2a3f1b12fb6cbc020b126f3125f0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#gadf4d2a3f1b12fb6cbc020b126f3125f0">mqtt_client_connect</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *<a class="el" href="structip__addr.html">ip_addr</a>, u16_t port, <a class="el" href="group__mqtt.html#ga8558743bdb7d599a93844fbc56c9029f">mqtt_connection_cb_t</a> cb, void *arg, const struct <a class="el" href="structmqtt__connect__client__info__t.html">mqtt_connect_client_info_t</a> *client_info)</td></tr>
<tr class="separator:gadf4d2a3f1b12fb6cbc020b126f3125f0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga73d8dd718bce09bfaab452770b4f76e6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga73d8dd718bce09bfaab452770b4f76e6">mqtt_disconnect</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client)</td></tr>
<tr class="separator:ga73d8dd718bce09bfaab452770b4f76e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga98f0fd168112b8b7db59bcd7a325a5c5"><td class="memItemLeft" align="right" valign="top">u8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__mqtt.html#ga98f0fd168112b8b7db59bcd7a325a5c5">mqtt_client_is_connected</a> (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client)</td></tr>
<tr class="separator:ga98f0fd168112b8b7db59bcd7a325a5c5"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<pre class="fragment">MQTT client for lwIP

Author: Erik Andersson

Details of the MQTT protocol can be found at:
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html 

-----------------------------------------------------------------
1. Initial steps, reserve memory and make connection to server:

1.1: Provide storage

Static allocation:
  mqtt_client_t static_client;
  example_do_connect(&amp;static_client);

Dynamic allocation:
  mqtt_client_t *client = mqtt_client_new();
  if(client != NULL) {
    example_do_connect(&amp;client);
  }
  
1.2: Establish Connection with server

void example_do_connect(mqtt_client_t *client)
{
  struct mqtt_connect_client_info_t ci;
  err_t err;
  
  /* Setup an empty client info structure */
  memset(&amp;ci, 0, sizeof(ci));
  
  /* Minimal amount of information required is client identifier, so set it here */ 
  ci.client_id = "lwip_test";
  
  /* Initiate client and connect to server, if this fails immediately an error code is returned
     otherwise mqtt_connection_cb will be called with connection result after attempting 
     to establish a connection with the server. 
     For now MQTT version 3.1.1 is always used */
  
  err = mqtt_client_connect(client, ip_addr, MQTT_PORT, mqtt_connection_cb, 0, &amp;ci);
  
  /* For now just print the result code if something goes wrong */
  if(err != ERR_OK) {
    printf("mqtt_connect return %d\n", err);
  }
}

Connection to server can also be probed by calling mqtt_client_is_connected(client) 

-----------------------------------------------------------------
2. Implementing the connection status callback


static void mqtt_connection_cb(mqtt_client_t *client, void *arg, mqtt_connection_status_t status)
{
  err_t err;
  if(status == MQTT_CONNECT_ACCEPTED) {
    printf("mqtt_connection_cb: Successfully connected\n");
    
    /* Setup callback for incoming publish requests */
    mqtt_set_inpub_callback(client, mqtt_incoming_publish_cb, mqtt_incoming_data_cb, arg);
    
    /* Subscribe to a topic named "subtopic" with QoS level 1, call mqtt_sub_request_cb with result */ 
    err = mqtt_subscribe(client, "subtopic", 1, mqtt_sub_request_cb, arg);

    if(err != ERR_OK) {
      printf("mqtt_subscribe return: %d\n", err);
    }
  } else {
    printf("mqtt_connection_cb: Disconnected, reason: %d\n", status);
    
    /* Its more nice to be connected, so try to reconnect */
    example_do_connect(client);
  }  
}

static void mqtt_sub_request_cb(void *arg, err_t result)
{
  /* Just print the result code here for simplicity, 
     normal behaviour would be to take some action if subscribe fails like 
     notifying user, retry subscribe or disconnect from server */
  printf("Subscribe result: %d\n", result);
}

-----------------------------------------------------------------
3. Implementing callbacks for incoming publish and data

/* The idea is to demultiplex topic and create some reference to be used in data callbacks
   Example here uses a global variable, better would be to use a member in arg
   If RAM and CPU budget allows it, the easiest implementation might be to just take a copy of
   the topic string and use it in mqtt_incoming_data_cb
*/
static int inpub_id;
static void mqtt_incoming_publish_cb(void *arg, const char *topic, u32_t tot_len)
{
  printf("Incoming publish at topic %s with total length %u\n", topic, (unsigned int)tot_len);

  /* Decode topic string into a user defined reference */
  if(strcmp(topic, "print_payload") == 0) {
    inpub_id = 0;
  } else if(topic[0] == 'A') {
    /* All topics starting with 'A' might be handled at the same way */
    inpub_id = 1;
  } else {
    /* For all other topics */
    inpub_id = 2;
  }
}

static void mqtt_incoming_data_cb(void *arg, const u8_t *data, u16_t len, u8_t flags)
{
  printf("Incoming publish payload with length %d, flags %u\n", len, (unsigned int)flags);

  if(flags &amp; MQTT_DATA_FLAG_LAST) {
    /* Last fragment of payload received (or whole part if payload fits receive buffer
       See MQTT_VAR_HEADER_BUFFER_LEN)  */

    /* Call function or do action depending on reference, in this case inpub_id */
    if(inpub_id == 0) {
      /* Don't trust the publisher, check zero termination */
      if(data[len-1] == 0) {
        printf("mqtt_incoming_data_cb: %s\n", (const char *)data);
      }
    } else if(inpub_id == 1) {
      /* Call an 'A' function... */
    } else {
      printf("mqtt_incoming_data_cb: Ignoring payload...\n");
    }
  } else {
    /* Handle fragmented payload, store in buffer, write to file or whatever */
  }
}

-----------------------------------------------------------------
4. Using outgoing publish


void example_publish(mqtt_client_t *client, void *arg)
{
  const char *pub_payload= "PubSubHubLubJub";
  err_t err;
  u8_t qos = 2; /* 0 1 or 2, see MQTT specification */
  u8_t retain = 0; /* No don't retain such crappy payload... */
  err = mqtt_publish(client, "pub_topic", pub_payload, strlen(pub_payload), qos, retain, mqtt_pub_request_cb, arg);
  if(err != ERR_OK) {
    printf("Publish err: %d\n", err);
  }
}

/* Called when publish is complete either with sucess or failure */
static void mqtt_pub_request_cb(void *arg, err_t result)
{
  if(result != ERR_OK) {
    printf("Publish result: %d\n", result);
  }
}

-----------------------------------------------------------------
5. Disconnecting

Simply call mqtt_disconnect(client)
</pre> <h2 class="groupheader">Macro Definition Documentation</h2>
<a id="gaa8632baff6bbb5004385998918f1e6bd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa8632baff6bbb5004385998918f1e6bd">&#9670;&nbsp;</a></span>MQTT_PORT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MQTT_PORT&#160;&#160;&#160;<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0a172d486d82c552ef3540cf8d61b14b22">LWIP_IANA_PORT_MQTT</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Default MQTT port (non-TLS) </p>

</div>
</div>
<a id="ga83d6a6d811b201a74d793bc1b5d4e029"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga83d6a6d811b201a74d793bc1b5d4e029">&#9670;&nbsp;</a></span>mqtt_subscribe</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define mqtt_subscribe</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">client, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">topic, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">qos, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cb, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">arg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;<a class="el" href="group__mqtt.html#gafdb39d4a9758f98c02451aaa9a9b3103">mqtt_sub_unsub</a>(client, topic, qos, cb, arg, 1)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Subscribe to topic </p>

</div>
</div>
<a id="ga6610174f17b9ecbcf2bc66a4fd5a6b0f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga6610174f17b9ecbcf2bc66a4fd5a6b0f">&#9670;&nbsp;</a></span>MQTT_TLS_PORT</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MQTT_TLS_PORT&#160;&#160;&#160;<a class="el" href="group__iana.html#ggac9396d90585e49e9a287179bf5aa9ba0ab833e9dc7646bd7affde45691bc66601">LWIP_IANA_PORT_SECURE_MQTT</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Default MQTT TLS port </p>

</div>
</div>
<a id="ga0f133ef09cbe56c46ebe2cc21afccf3f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0f133ef09cbe56c46ebe2cc21afccf3f">&#9670;&nbsp;</a></span>mqtt_unsubscribe</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define mqtt_unsubscribe</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">client, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">topic, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cb, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">arg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;<a class="el" href="group__mqtt.html#gafdb39d4a9758f98c02451aaa9a9b3103">mqtt_sub_unsub</a>(client, topic, 0, cb, arg, 0)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Unsubscribe to topic </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="ga8558743bdb7d599a93844fbc56c9029f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8558743bdb7d599a93844fbc56c9029f">&#9670;&nbsp;</a></span>mqtt_connection_cb_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* mqtt_connection_cb_t) (<a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *client, void *arg, <a class="el" href="group__mqtt.html#ga8cf0f360ab20343af37e1d124395a77d">mqtt_connection_status_t</a> status)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Function prototype for mqtt connection status callback. Called when client has connected to the server after initiating a mqtt connection attempt by calling <a class="el" href="group__mqtt.html#gadf4d2a3f1b12fb6cbc020b126f3125f0">mqtt_client_connect()</a> or when connection is closed by server or an error</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client itself </td></tr>
    <tr><td class="paramname">arg</td><td>Additional argument to pass to the callback function </td></tr>
    <tr><td class="paramname">status</td><td>Connect result code or disconnection notification </td></tr>
  </table>
  </dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__mqtt.html#ga8cf0f360ab20343af37e1d124395a77d">mqtt_connection_status_t</a> </dd></dl>

</div>
</div>
<a id="gafec7e75fe6a746eef9ca411463446c81"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafec7e75fe6a746eef9ca411463446c81">&#9670;&nbsp;</a></span>mqtt_incoming_data_cb_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* mqtt_incoming_data_cb_t) (void *arg, const u8_t *data, u16_t len, u8_t flags)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Function prototype for MQTT incoming publish data callback function. Called when data arrives to a subscribed topic </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="group__mqtt.html#ga83d6a6d811b201a74d793bc1b5d4e029">mqtt_subscribe</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">arg</td><td>Additional argument to pass to the callback function </td></tr>
    <tr><td class="paramname">data</td><td>User data, pointed object, data may not be referenced after callback return, NULL is passed when all publish data are delivered </td></tr>
    <tr><td class="paramname">len</td><td>Length of publish data fragment </td></tr>
    <tr><td class="paramname">flags</td><td>MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga7116bb85255394cec4b1d9fa38842c29"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7116bb85255394cec4b1d9fa38842c29">&#9670;&nbsp;</a></span>mqtt_incoming_publish_cb_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* mqtt_incoming_publish_cb_t) (void *arg, const char *topic, u32_t tot_len)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Function prototype for MQTT incoming publish function. Called when an incoming publish arrives to a subscribed topic </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="group__mqtt.html#ga83d6a6d811b201a74d793bc1b5d4e029">mqtt_subscribe</a></dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">arg</td><td>Additional argument to pass to the callback function </td></tr>
    <tr><td class="paramname">topic</td><td>Zero terminated Topic text string, topic may not be referenced after callback return </td></tr>
    <tr><td class="paramname">tot_len</td><td>Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gacad2bbe2cee76eaa120cc63e2f6094fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gacad2bbe2cee76eaa120cc63e2f6094fd">&#9670;&nbsp;</a></span>mqtt_request_cb_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef void(* mqtt_request_cb_t) (void *arg, <a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> err)</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Function prototype for mqtt request callback. Called when a subscribe, unsubscribe or publish request has completed </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">arg</td><td>Pointer to user data supplied when invoking request </td></tr>
    <tr><td class="paramname">err</td><td>ERR_OK on success ERR_TIMEOUT if no response was received within timeout, ERR_ABRT if (un)subscribe was denied </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="ga99fb83031ce9923c84392b4e92f956b5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga99fb83031ce9923c84392b4e92f956b5">&#9670;&nbsp;</a></span>anonymous enum</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">anonymous enum</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Data callback flags </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga99fb83031ce9923c84392b4e92f956b5a79cd00d0a5a8df13207e0c49447df87f"></a>MQTT_DATA_FLAG_LAST&#160;</td><td class="fielddoc"><p>Flag set when last fragment of data arrives in data callback </p>
</td></tr>
</table>

</div>
</div>
<a id="ga8cf0f360ab20343af37e1d124395a77d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8cf0f360ab20343af37e1d124395a77d">&#9670;&nbsp;</a></span>mqtt_connection_status_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__mqtt.html#ga8cf0f360ab20343af37e1d124395a77d">mqtt_connection_status_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Connection status codes </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da074dc1d289b8e8d4aad91f6a2cb93dc1"></a>MQTT_CONNECT_ACCEPTED&#160;</td><td class="fielddoc"><p>Accepted </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da41f8aa97142be337cb639f94d9145190"></a>MQTT_CONNECT_REFUSED_PROTOCOL_VERSION&#160;</td><td class="fielddoc"><p>Refused protocol version </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da28ffe49b0175adaa2b9a27cb4873224a"></a>MQTT_CONNECT_REFUSED_IDENTIFIER&#160;</td><td class="fielddoc"><p>Refused identifier </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77dade28ec1c2ce3d874e91251d683c92b2a"></a>MQTT_CONNECT_REFUSED_SERVER&#160;</td><td class="fielddoc"><p>Refused server </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da290cf9037054c42022cc864cfade896a"></a>MQTT_CONNECT_REFUSED_USERNAME_PASS&#160;</td><td class="fielddoc"><p>Refused user credentials </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77dafc4888158dd6ee84269a5f0bfdc12b17"></a>MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_&#160;</td><td class="fielddoc"><p>Refused not authorized </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da321f5ce31b173f235de1a517fcfd00dd"></a>MQTT_CONNECT_DISCONNECTED&#160;</td><td class="fielddoc"><p>Disconnected </p>
</td></tr>
<tr><td class="fieldname"><a id="gga8cf0f360ab20343af37e1d124395a77da57153f2ab4331c6f76a9ee74e1bcfc62"></a>MQTT_CONNECT_TIMEOUT&#160;</td><td class="fielddoc"><p>Timeout </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gadf4d2a3f1b12fb6cbc020b126f3125f0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gadf4d2a3f1b12fb6cbc020b126f3125f0">&#9670;&nbsp;</a></span>mqtt_client_connect()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> mqtt_client_connect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__ipaddr.html#ga16ef96d6cde029029bbf47fee35fd67a">ip_addr_t</a> *&#160;</td>
          <td class="paramname"><em>ip_addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__mqtt.html#ga8558743bdb7d599a93844fbc56c9029f">mqtt_connection_cb_t</a>&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct <a class="el" href="structmqtt__connect__client__info__t.html">mqtt_connect_client_info_t</a> *&#160;</td>
          <td class="paramname"><em>client_info</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Connect to MQTT server </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
    <tr><td class="paramname"><a class="el" href="structip__addr.html">ip_addr</a></td><td>Server IP </td></tr>
    <tr><td class="paramname">port</td><td>Server port </td></tr>
    <tr><td class="paramname">cb</td><td>Connection state change callback </td></tr>
    <tr><td class="paramname">arg</td><td>User supplied argument to connection callback </td></tr>
    <tr><td class="paramname">client_info</td><td>Client identification and connection options </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if successful, </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> enum for other results </dd></dl>

</div>
</div>
<a id="gaa0fa1d985c322a9c91a51322db254882"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa0fa1d985c322a9c91a51322db254882">&#9670;&nbsp;</a></span>mqtt_client_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mqtt_client_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Free MQTT client instance </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>Pointer to instance to be freed </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga98f0fd168112b8b7db59bcd7a325a5c5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga98f0fd168112b8b7db59bcd7a325a5c5">&#9670;&nbsp;</a></span>mqtt_client_is_connected()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u8_t mqtt_client_is_connected </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Check connection with server </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1 if connected to server, 0 otherwise </dd></dl>

</div>
</div>
<a id="gae7e19e236eb6122c8c39e93db6f5f53f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae7e19e236eb6122c8c39e93db6f5f53f">&#9670;&nbsp;</a></span>mqtt_client_new()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a>* mqtt_client_new </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Create a new MQTT client instance </p><dl class="section return"><dt>Returns</dt><dd>Pointer to instance on success, NULL otherwise </dd></dl>

</div>
</div>
<a id="ga73d8dd718bce09bfaab452770b4f76e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga73d8dd718bce09bfaab452770b4f76e6">&#9670;&nbsp;</a></span>mqtt_disconnect()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mqtt_disconnect </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Disconnect from MQTT server </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gade9850d716e81fde572cb012be795d2f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gade9850d716e81fde572cb012be795d2f">&#9670;&nbsp;</a></span>mqtt_publish()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> mqtt_publish </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>topic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>payload</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>payload_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>qos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>retain</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__mqtt.html#gacad2bbe2cee76eaa120cc63e2f6094fd">mqtt_request_cb_t</a>&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>MQTT publish function. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
    <tr><td class="paramname">topic</td><td>Publish topic string </td></tr>
    <tr><td class="paramname">payload</td><td>Data to publish (NULL is allowed) </td></tr>
    <tr><td class="paramname">payload_length</td><td>Length of payload (0 is allowed) </td></tr>
    <tr><td class="paramname">qos</td><td>Quality of service, 0 1 or 2 </td></tr>
    <tr><td class="paramname">retain</td><td>MQTT retain flag </td></tr>
    <tr><td class="paramname">cb</td><td>Callback to call when publish is complete or has timed out </td></tr>
    <tr><td class="paramname">arg</td><td>User supplied argument to publish callback </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if successful ERR_CONN if client is disconnected ERR_MEM if short on memory </dd></dl>

</div>
</div>
<a id="gafdfa0e65b217e92835d35858924565cf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafdfa0e65b217e92835d35858924565cf">&#9670;&nbsp;</a></span>mqtt_set_inpub_callback()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mqtt_set_inpub_callback </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__mqtt.html#ga7116bb85255394cec4b1d9fa38842c29">mqtt_incoming_publish_cb_t</a>&#160;</td>
          <td class="paramname"><em>pub_cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__mqtt.html#gafec7e75fe6a746eef9ca411463446c81">mqtt_incoming_data_cb_t</a>&#160;</td>
          <td class="paramname"><em>data_cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set callback to handle incoming publish requests from server </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
    <tr><td class="paramname">pub_cb</td><td>Callback invoked when publish starts, contain topic and total length of payload </td></tr>
    <tr><td class="paramname">data_cb</td><td>Callback for each fragment of payload that arrives </td></tr>
    <tr><td class="paramname">arg</td><td>User supplied argument to both callbacks </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gafdb39d4a9758f98c02451aaa9a9b3103"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gafdb39d4a9758f98c02451aaa9a9b3103">&#9670;&nbsp;</a></span>mqtt_sub_unsub()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> mqtt_sub_unsub </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structmqtt__client__s.html">mqtt_client_t</a> *&#160;</td>
          <td class="paramname"><em>client</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>topic</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>qos</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__mqtt.html#gacad2bbe2cee76eaa120cc63e2f6094fd">mqtt_request_cb_t</a>&#160;</td>
          <td class="paramname"><em>cb</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>sub</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>MQTT subscribe/unsubscribe function. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">client</td><td>MQTT client </td></tr>
    <tr><td class="paramname">topic</td><td>topic to subscribe to </td></tr>
    <tr><td class="paramname">qos</td><td>Quality of service, 0 1 or 2 (only used for subscribe) </td></tr>
    <tr><td class="paramname">cb</td><td>Callback to call when subscribe/unsubscribe reponse is received </td></tr>
    <tr><td class="paramname">arg</td><td>User supplied argument to publish callback </td></tr>
    <tr><td class="paramname">sub</td><td>1 for subscribe, 0 for unsubscribe </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if successful, </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> enum for other results </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
